//------------------------------------------------
//		main.c
//	Minimalist Example
//	Arthur Benemann 13/11/2010
//------------------------------------------------
//
//	Description:
//  Minimal code without using any library to blink a led on the picDev
//
//------------------------------------------------

#include "p24fxxxx.h"       // Compiler header file

//-------------------- CONFIGURATION --------------------
// Disables memomory protection
_CONFIG3(WPDIS_WPDIS & WPCFG_WPCFGDIS);
// Primary oscillator with PLL, High Speed OSC, Usb vreg on, Clock switching enabled, Two speed start-up enabled, PLL with a 12MHz OSC
_CONFIG2(FNOSC_PRIPLL  & POSCMOD_HS & DISUVREG_ON & IOL1WAY_OFF  & FCKSM_CSECMD & IESO_ON & PLLDIV_DIV3);
// Use PGD2 and PGC2 pins for debbuging, Disable wathchdog, Disable JTAG
_CONFIG1(ICS_PGx2 & FWDTEN_OFF & JTAGEN_OFF);


//-------------------- Main Loop -----------------------
int main( void)
{
    long i;                     // Variable used in the delay.

    _TRISD1 = 0;                // Config LED pin as an output
    
    // main loop
    while(1)
    {
        _RD1 = 1;                // Turn on the led.
        for(i=500000;i>0;i--); // Delay of about 0.5s.
        _RD1 = 0;                // Turn off the led.
        for(i=500000;i>0;i--); // Delay of about 0.5s.
    };
}
